<template>
  <div class="box">
    <!-- 卡片 -->
    <div class="top">
      <xCard
        :title="'折线图数据'"
        width="800px"
        style="margin-right: 16px;"
        @getShare="getShare"
      >
        <div
          id="chart"
          class="parent"
        >
        </div>
      </xCard>
      <xCard
        :title="'饼图数据'"
        width="400px"
        @getShare="getShare"
      >
        <div
          id="chart2"
          class="parent"
        >
        </div>
      </xCard>
    </div>
    <CollapseCard
      :title="title"
      style="margin-top: 10px;"
    >
      <template v-slot:titleSlot>
      </template>
      <div style="padding: 10px 20px;">
        asdasjdjajsdjjsajdjsajdjas
      </div>
    </CollapseCard>
  </div>
</template>

<script>
import CollapseCard from './cards/collapseCard.vue'
import * as echarts from 'echarts'
import xCard from './cards/card.vue'
import bgCard from './cards/bgCard.vue'

export default {
  components: {
    CollapseCard,
    xCard,
    bgCard
  },
  props: {},
  data () {
    return {
      title: 'XXXXX信息',
      centerDialogVisible: false
    };
  },
  computed: {},
  watch: {},
  created () { },
  mounted () {
    this.getEcharts()
    this.getEcharts2()
  },
  methods: {
    getEcharts () {
      var chartDom = document.getElementById('chart')
      const myChart = echarts.init(chartDom)
      const option = {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            lineStyle: {
              color: '#FEDAB7',
              type: 'solid',
              width: 2
            }
          },
          showContent: true,
        },
        color: ['#B2C9E4', '#2C3838'],
        legend: {
          top: 20,
          right: 10,
          data: ['数据一', '数据二'],
          textStyle: {
            color: '#ccc',
          }
        },
        grid: {
          top: '20%',
          left: '3%',
          right: '4%',
          bottom: '6%',
          containLabel: true
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['壹月', '贰月', '叁月', '肆月', '伍月', '陸月', '柒月', '捌月', '玖月', '拾月', '拾壹月', '拾贰月'],
          axisLine: {
            show: true,
            symbolSize: [6, 10],
            lineStyle: {
              color: '#ccc',
            }
          },
          axisTick: {
            show: false,
          }
        },
        yAxis: {
          type: 'value',
          axisLine: {
            show: false,
            lineStyle: {
              color: '#ccc',
            }
          }
        },
        series: [
          {
            name: '数据一',
            type: 'line',
            symbol: 'emptyCircle',
            legendHoverLink: true,
            symbolSize: 8,
            stack: 'Total',
            lineStyle: {
              shadowColor: 'rgba(0, 0, 0, 0.2)',
              shadowBlur: 5,
              shadowOffsetX: 2,
              shadowOffsetY: 3,
              opacity: 1,
            },
            data: [120, 132, 101, 134, 90, 230, 210, 134, 90, 230, 21, 62]
          },
          {
            name: '数据二',
            type: 'line',
            symbol: 'emptyCircle',
            legendHoverLink: true,
            symbolSize: 8,
            stack: 'Total',
            lineStyle: {
              shadowColor: 'rgba(0, 0, 0, 0.2)',
              shadowBlur: 5,
              shadowOffsetX: 2,
              shadowOffsetY: 3,
              opacity: 1,
            },
            data: [220, 182, 191, 234, 290, 330, 310, 90, 230, 210, 134, 90]
          }
        ]
      }
      option && myChart.setOption(option)
    },
    getEcharts2 () {
      var chartDom = document.getElementById('chart2')
      const myChart = echarts.init(chartDom)
      const option = {
        title: {
          text: 'Referer of a Website',
          subtext: 'Fake Data',
          left: 'center'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          show: false,
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: '50%',
            data: [
              { value: 1048, name: 'Search Engine' },
              { value: 735, name: 'Direct' },
              { value: 580, name: 'Email' },
              { value: 484, name: 'Union Ads' },
              { value: 300, name: 'Video Ads' }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      }
      option && myChart.setOption(option)
    },
    getShare () {
      this.centerDialogVisible = true
    }
  },
}
</script>
<style lang='less' scoped>
.parent {
  width: 100%;
  height: 30vh;
}
.top {
  display: flex;
}
</style>